package com.ch.ms.server.world;

import com.ch.ms.dto.MapleWorldServerDto;
import com.ch.ms.server.base.AbstractMapleServer;
import com.ch.ms.server.base.MaplePacketHandler;
import com.ch.ms.server.base.configuration.MapleServerBindConfiguration;
import com.ch.ms.server.base.configuration.motan.MotanReferers;
import com.ch.ms.server.packet.MaplePacket;
import com.ch.ms.server.packet.MaplePacketHeader;
import com.ch.ms.service.MapleServerManageService;
import com.weibo.api.motan.config.springsupport.annotation.MotanReferer;
import io.netty.channel.ChannelHandler;
import lombok.Getter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;


@Component
public class MapleWorldServer extends AbstractMapleServer {
    @Autowired
    public MapleWorldServer(MapleServerBindConfiguration bindConfiguration) {
        this.bindConfiguration = bindConfiguration;
    }

    @Override
    public List<ChannelHandler> getChannelHandlers() {
        return null;
    }

    @Override
    public Map<MaplePacketHeader, Class<? extends MaplePacket>> getSupportedPackets() {
        return null;
    }

    @Override
    public Map<MaplePacketHeader, MaplePacketHandler> getPacketHandlers() {
        return null;
    }

    @Override
    public String getName() {
        return "冒险岛世界服务器";
    }


    @Getter
    private final MapleServerBindConfiguration bindConfiguration;

    @MotanReferer(basicReferer = MotanReferers.CHMS_BASIC_REFERER_CONFIG)
    private MapleServerManageService<MapleWorldServerDto> serverManageService;


    @Override
    public void afterBind() {
        serverManageService.register(MapleWorldServerDto.builder().uuid(getId()).name(getName()).host(bindConfiguration.getHost()).port(bindConfiguration.getPort()).build());
    }
}
